#include <iostream>

void
print(std::size_t value, int base = 10)
{
  char* s = new char();
  char* p = s;
  
  while (value > 0)
    {
      std::size_t r = value % base;
      value = value / base;

      if (r < 10)
	{
	  *s++ = '0' + r;
	}
      else
	{
	  *s++ = 'A' + r - 10;
	}
    }

  while (s != p)
    {
      std::cerr << *(--s);
    }

  std::cerr << std::endl;
}

int 
main()
{
  print(45);
  print(45, 2);
  print(45, 8);
  print(45, 16);
}
